home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / MoreFiles 1.3.1 / Search.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-16  |  6.6 KB  |  173 lines  |  [TEXT/MMCC]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    IndexedSearch and the PBCatSearch compatibility function.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support
  7. **
  8. **    File:        Search.h
  9. **
  10. **    Copyright © 1992-1995 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #ifndef __SEARCH__
  23. #define __SEARCH__
  24.  
  25. #include <Types.h>
  26. #include <Files.h>
  27.  
  28. /*****************************************************************************/
  29.  
  30. pascal    OSErr    IndexedSearch(CSParamPtr pb,
  31.                               long dirID);
  32. /*    ¶ Search in and below a directory.
  33.     The IndexedSearch function performs an indexed search in and below the
  34.     specified directory using the same parameters (in pb) as is passed to
  35.     PBCatSearch. See Inside Macintosh: Files for a description of the
  36.     parameter block.
  37.     
  38.     pb            input:    A CSParamPtr record specifying the volume to search
  39.                         and the search criteria.
  40.                 output:    Fields in the parameter block are returned indicating
  41.                         the number of matches found, the matches, and if the
  42.                         search ended with noErr, the CatPosition record that
  43.                         lets you resume a search where the last search left
  44.                         off.
  45.     dirID        input:    The directory to search. If fsRtDirID is passed,
  46.                         the entire volume is searched.
  47.     
  48.     Note:    If you use a high-level debugger and use ioSearchTime to limit
  49.             the length of time to run the search, you'll want to step over
  50.             calls to IndexedSearch because it installs a Time Manager task.
  51.             Most high-level debuggers don't deal gracefully with interrupt
  52.             driven code.
  53.     
  54.     __________
  55.     
  56.     See also:    PBCatSearch, PBCatSearchSyncCompat
  57. */
  58.  
  59. /*****************************************************************************/
  60.  
  61. pascal    OSErr    PBCatSearchSyncCompat(CSParamPtr paramBlock);
  62. /*    ¶ Search a volume using PBCatSearch or IndexedSearch.
  63.     The PBCatSearchSyncCompat function uses PBCatSearch (if available) or
  64.     IndexedSearch (if PBCatSearch is not available) to search a volume
  65.     using a set of search criteria that you specify. It builds a list of all
  66.     files or directories that meet your specifications.
  67.     
  68.     pb            input:    A CSParamPtr record specifying the volume to search
  69.                         and the search criteria.
  70.                 output:    Fields in the parameter block are returned indicating
  71.                         the number of matches found, the matches, and if the
  72.                         search ended with noErr, the CatPosition record that
  73.                         lets you resume a search where the last search left
  74.                         off.
  75.     
  76.     Note:    If you use a high-level debugger and use ioSearchTime to limit
  77.             the length of time to run the search, you'll want to step over
  78.             calls to PBCatSearchSyncCompat because it calls IndexedSearch
  79.             which installs a Time Manager task. Most high-level debuggers
  80.             don't deal gracefully with interrupt driven code.
  81.     
  82.     __________
  83.     
  84.     See also:    PBCatSearch, IndexedSearch
  85. */
  86.  
  87. /*****************************************************************************/
  88.  
  89. pascal    OSErr    NameFileSearch(StringPtr volName,
  90.                                short vRefNum,
  91.                                ConstStr255Param fileName,
  92.                                FSSpecPtr matches,
  93.                                long reqMatchCount,
  94.                                long *actMatchCount,
  95.                                Boolean newSearch,
  96.                                Boolean partial);
  97. /*    ¶ Search for files by file name with PBCatSearch.
  98.     The NameFileSearch function searches for files with a specific file
  99.     name on a volume that supports PBCatSearch.
  100.     Note: A result of catChangedErr means the catalog has changed between
  101.     searches, but the search can be continued with the possiblity that you
  102.     may miss some matches or get duplicate matches.  For all other results
  103.     (except for noErr), the search cannot be continued.
  104.  
  105.     volName            input:    A pointer to the name of a mounted volume
  106.                             or nil.
  107.     vRefNum            input:    Volume specification.
  108.     fileName        input:    The name of the file to search for.
  109.     matches            input:    Pointer to array of FSSpec where the match list is
  110.                             returned.
  111.     reqMatchCount    input:    Maximum number of matches to return    (the number of
  112.                             elements in the matches array).
  113.     actMatchCount    output: The number of matches actually returned.
  114.     newSearch        input:    If true, start a new search. If false and if
  115.                             vRefNum is the same as the last call to
  116.                             NameFileSearch, then start searching at the
  117.                             position where the last search left off.
  118.     partial            input:    If the partial parameter is false, then only files
  119.                             that exactly match fileName will be found.  If the
  120.                             partial parameter is true, then all file names that
  121.                             contain fileName will be found.
  122.  
  123.     __________
  124.     
  125.     Also see:    CreatorTypeFileSearch
  126. */
  127.  
  128. /*****************************************************************************/
  129.  
  130. pascal    OSErr    CreatorTypeFileSearch(StringPtr volName,
  131.                                       short vRefNum,
  132.                                       OSType creator,
  133.                                       OSType fileType,
  134.                                       FSSpecPtr matches,
  135.                                       long reqMatchCount,
  136.                                       long *actMatchCount,
  137.                                       Boolean newSearch);
  138. /*    ¶ Search for files by creator/fileType with PBCatSearch.
  139.     The CreatorTypeFileSearch function searches for files with a specific
  140.     creator or fileType on a volume that supports PBCatSearch.
  141.     Note: A result of catChangedErr means the catalog has changed between
  142.     searches, but the search can be continued with the possiblity that you
  143.     may miss some matches or get duplicate matches.  For all other results
  144.     (except for noErr), the search cannot be continued.
  145.  
  146.     volName            input:    A pointer to the name of a mounted volume
  147.                             or nil.
  148.     vRefNum            input:    Volume specification.
  149.     creator            input:    The creator type of the file to search for.
  150.                             To ignore the creator type, pass 0x00000000 in
  151.                             this field.
  152.     fileType        input:    The file type of the file to search for.
  153.                             To ignore the file type, pass 0x00000000 in
  154.                             this field.
  155.     matches            input:    Pointer to array of FSSpec where the match list is
  156.                             returned.
  157.     reqMatchCount    input:    Maximum number of matches to return    (the number of
  158.                             elements in the matches array).
  159.     actMatchCount    output: The number of matches actually returned.
  160.     newSearch        input:    If true, start a new search. If false and if
  161.                             vRefNum is the same as the last call to
  162.                             CreatorTypeFileSearch, then start searching at the
  163.                             position where the last search left off.
  164.  
  165.     __________
  166.     
  167.     Also see:    NameFileSearch
  168. */
  169.  
  170. /*****************************************************************************/
  171.  
  172. #endif    /* __SEARCH__ */
  173.